package com.topisv.tms.repository.stock.instorage;

import java.util.List;

import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import com.topisv.tms.entity.stock.instorage.InstorageCountItem;

/**
 * 入库点收明细_dao
 * @author ch
 *
 */
public interface InstorageCountItemDao extends PagingAndSortingRepository<InstorageCountItem, Long>, JpaSpecificationExecutor<InstorageCountItem> {

	@Query("select t from InstorageCountItem t where t.taskCode=?1 and t.instorageType=?2")
	List<InstorageCountItem> loadByTaskCode(String taskCode, String instorageType);

	@Query("select t from InstorageCountItem t where t.uptaskCode=?")
	List<InstorageCountItem> loadByUpTaskCode(String uptaskCode);
	
	@Query("select t from InstorageCountItem t where t.billCode=?")
	List<InstorageCountItem> loadByBillCode(String billCode);
	
	@Query("select t from InstorageCountItem t where t.taskCode=?")
	List<InstorageCountItem> findByTaskCode(String taskCode);

	@Query("select t from InstorageCountItem t where t.uptaskCode=?1 and t.boxCode=?2")
	InstorageCountItem loadByCondition(String uptaskCode, String boxCode);

	@Query("select t from InstorageCountItem t where t.uptaskCode=?1 and ( t.upStatus='unup' or t.upStatus='uping' ) ")
	List<InstorageCountItem> loadUnupItem(String uptaskCode);
	
}